<template lang="pug">
.header
  .header-title 有料平台管理系统
  .header-user
    .header-user-btn(@click="changepwd")
      i.iconfont.icon-changepwd
      label 修改密码
    .header-user-btn(@click="logout")
      i.iconfont.icon-logout
      label 退出登录
</template>

<script>
import { mapState, mapActions } from 'vuex'
import { postLogout } from 'api'
export default {
  name: 'appHeader',
  data () {
    return {
      titleType: 'all',
      show: false,
      form: {
        
      }
    }
  },
  methods: {
    ...mapActions([
      'changeShowpwd'
    ]),
    changepwd () {
      this.changeShowpwd(true)
    },
    handleClose () {},
    beforeOpen () {},
    async logout () {
      this.$confirm('是否退出当前账号？', '退出登录', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        try {
          await this.$axios.post(postLogout)
          this.$message({ message: '退出登录', type: 'success' })
          this.$router.replace({ name: 'login' })
        } catch (err) {
          console.log(err)
          this.$message.error(err.message || err.ResultSet.errors)
        }
      })
    },
    // async getSpByDirectory () {
    //   try {
    //     const { data } = await this.$axios.get(getSpByDirectory)
    //     this.changeSuppliers(data)
    //   } catch (err) {
    //     this.$message.error(err.msg)
    //   }
    // },
    resetPswd () {
      this.$router.push({name: 'password'})
    }
  },
  computed: {
    title () {
      return this.$route.meta.title
    },
    ...mapState({
      lowerSidebarShow: state => state.ui.lowerSidebar.show,
      userInfo: state => state.user.user
    })
  }
}
</script>

<style lang="scss">
.header-popover {
  &.el-popover {
    padding: 0 !important;
  }
}
</style>

<style lang="scss" scoped>
.header {
  position: fixed;
  top: 0;
  width: calc(100% - 112px);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 0 24px;
  background: #FFFFFF;
  box-shadow: 0px 5px 10px 0px rgba(0, 0, 0, 0.05);
}
.header-title {
  font-size: 16px;
  font-weight: 600;
  color: #3E4373;
  line-height: 24px;
}
.header-handle {
  position: relative;
  .icon-user {
    cursor: pointer;
    font-size: 24px;
    color: #999;
  }
}
.login-info-title {
  font-size: 13px;
  font-weight: 400;
  color: #CCCCCC;
  line-height: 18px;
}
.login-info-container {
  padding: 10px;
}
.login-info-detail {
  display: flex;
  align-items: center;
  margin-top: 10px;
  .login-info-account {
    font-size: 14px;
    font-weight: 600;
    color: #000000;
    line-height: 20px;
  }
  .logo-info-userType {
    padding: 0 5px;
    height: 20px;
    line-height: 20px;
    border-radius: 2px;
    border: 1px solid #FF5500;
    margin-left: 5px;
    color: #FF5500;
    cursor: pointer;
  }
  .login-info-tag {
    margin-left: 5px;
    padding: 2px 5px;
    background: #FFF6F2;
    border-radius: 2px;
    border: 1px solid #FF5500;
    font-size: 12px;
    font-weight: 400;
    color: #FF6213;
    line-height: 17px;
  }
}
.login-info-section {
  padding: 0 14px;
  height: 40px;
  border-top: 1px solid #D9D9D9;
  display: flex;
  align-items: center;
  cursor: pointer;
}
.toggle-title {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 400;
  color: #333333;
  line-height: 18px;
  .icon-transform {
    font-size: 12px;
  }
}
.login-handle {
  background: #F4F4F4;
  box-shadow: 0px -1px 0px 0px #D9D9D9;
  border-radius: 0px 0px 2px 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  cursor: pointer;
  .login-handle-text {
    font-size: 13px;
    font-weight: 400;
    color: #000000;
    line-height: 18px;
  }
}
.header-user {
  display: flex;
  align-items: center;
}
.header-user-system {
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 400;
  color: #FF4200;
  line-height: 17px;
  border: 1px solid #FF4200;
  border-radius: 10px;
  margin-right: 10px;
}
.header-user-name {
  margin-right: 10px;
  font-size: 13px;
  font-weight: 400;
  color: #333333;
  line-height: 18px;
}
.header-user-handle {
  display: flex;
  align-items: center;
  margin-right: 50px;
  .header-handle-item {
    cursor: pointer;
    margin-left: 20px;
    font-size: 14px;
    font-weight: 400;
    color: #333333;
    line-height: 20px;
  }
}

.service {
  width: 300px;
  height: 120px;
  padding: 30px;
  display: flex;
  align-items: center;
}
.service-icon {
  width: 60px;
  height: 60px;
  margin-right: 15px;
}
.service-title {
  line-height: 17px;
  font-size: 12px;
  font-weight: 400;
  color: #999999;
  span {
    vertical-align: middle;
  }
}
.icon-phone {
  font-size: 20px;
  vertical-align: middle;
}
.service-number {
  font-size: 18px;
  font-weight: bold;
  color: #000000;
  line-height: 21px;
}
.service-date {
  font-size: 13px;
  font-weight: 400;
  color: #333333;
  line-height: 18px;
}
.header-user {
  .header-user-btn {
    height: 32px;
    padding: 4px 10px;
    background: #F6F6F9;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    cursor: pointer;
  }
  .iconfont {
    font-size: 18px;
    color: #B6B8CA;
    margin-right: 4px;
  }
  label {
    font-size: 14px;
    line-height: 18px;
    color: #64698F;
  }
}
</style>
